﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Transactions.aspx.cs" Inherits="WebTraderLite.Pages.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <ajaxToolkit:ToolkitScriptManager ID="sm" runat="server"></ajaxToolkit:ToolkitScriptManager>
    <!-- Add tab container -->
    <ajaxToolkit:TabContainer ID="tabContainerTransactions" runat="server" 
        ActiveTabIndex="3" Width="674px">
        
        <ajaxToolkit:TabPanel runat="server" HeaderText="Portfolio" ID="tabPortfolio"><ContentTemplate>
                <asp:GridView ID="gridViewPortfolio" runat="server"
                Style="float:left; text-align:justify" Height="24px" 
                    ShowHeaderWhenEmpty="True" DataKeyNames="Stock">
                    <Columns>
                        <asp:HyperLinkField DataNavigateUrlFields="Stock" DataNavigateUrlFormatString="~/Pages/SellStock.aspx?stock={0}"
                            Text="Sell" />
                    </Columns>
                    <Columns>
                        <asp:HyperLinkField DataNavigateUrlFields="Stock" DataNavigateUrlFormatString="~/Pages/AutoSell.aspx?stock={0}"
                            Text="Auto-Sell" />
                    </Columns>
                </asp:GridView>
            
            
</ContentTemplate>
</ajaxToolkit:TabPanel>
    
        <ajaxToolkit:TabPanel ID="tabAutoEvents" runat="server" HeaderText="Scheduled Auto-Transactions"><ContentTemplate>
                <!-- Add tab container inside auto-transaction panel to hold different types of auto-transactions-->
                <ajaxToolkit:TabContainer ID="tabConatainerAutoEvents" runat="server" 
                    ActiveTabIndex="2" CssClass="" Width="653px" ><ajaxToolkit:TabPanel ID="tabAutoBuy" runat="server" HeaderText="Auto-Buy">
                        <ContentTemplate>
                            <asp:GridView ID="gridViewAutoBuy" runat="server" 
                                DataSourceID="autoBuySqlDataSource" AutoGenerateColumns="False" 
                                DataKeyNames="stockSymbol,loginName" 
                                onrowdeleting="gridViewAutoBuy_RowDeleting">
                                <Columns>
                                    <asp:BoundField DataField="stockSymbol" HeaderText="Stock" />
                                    <asp:BoundField DataField="purchasePrice" DataFormatString="{0:C}" 
                                        HeaderText="Buy Price" />
                                    <asp:BoundField DataField="noofShare" HeaderText="Num Shares" />
                                    <asp:CommandField ShowDeleteButton="True" />
                                    <asp:BoundField DataField="loginName" Visible="False" />
                                </Columns>
                            </asp:GridView>
                            <asp:SqlDataSource ID="autoBuySqlDataSource" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:webtraderliteConnectionString %>" 
                                DeleteCommand="DELETE FROM autobuy WHERE (loginName = @loginName) AND (stockSymbol = @stockSymbol)" 
                                ProviderName="<%$ ConnectionStrings:webtraderliteConnectionString.ProviderName %>" 
                                
                                SelectCommand="SELECT loginName, stockSymbol, purchasePrice, noofShare FROM autobuy WHERE (loginName = @userName)" 
                                ondeleting="autoBuySqlDataSource_Deleting">
                                <DeleteParameters>
                                    <asp:Parameter Name="stockSymbol" Type="String" />
                                    <asp:Parameter Name="loginName" Type="String" />
                                </DeleteParameters>
                                </asp:SqlDataSource>
                        </ContentTemplate>
                    </ajaxToolkit:TabPanel>
<ajaxToolkit:TabPanel ID="tabAutoSell" runat="server" HeaderText="Auto-Sell">
    <ContentTemplate>
        <asp:GridView ID="gridViewAutoSell" runat="server" 
            DataSourceID="autoSellSqlDataSource" AutoGenerateColumns="False" 
            DataKeyNames="stockSymbol" RowStyle-Width="75px">
            <Columns>
                <asp:BoundField DataField="stockSymbol" HeaderText="Stock" ReadOnly="True" 
                    SortExpression="stockSymbol" />
                <asp:BoundField DataField="lastpurchasePrice" HeaderText="Purchased At" 
                    SortExpression="lastpurchasePrice" />
                <asp:BoundField DataField="trendtoMonitor" HeaderText="Sell if Stock Goes " 
                    SortExpression="trendtoMonitor" />
                <asp:BoundField DataField="sellPrice" DataFormatString="{0:C}" 
                    HeaderText="Sell Price" SortExpression="sellPrice" />
                <asp:BoundField DataField="noofShare" HeaderText="Num Shares to Sell" 
                    SortExpression="noofShare" />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="autoSellSqlDataSource" runat="server" 
            ConnectionString="<%$ ConnectionStrings:webtraderliteConnectionString %>" 
            ProviderName="<%$ ConnectionStrings:webtraderliteConnectionString.ProviderName %>" 
            SelectCommand="SELECT autosell.sellPrice, autosell.noofShare, autosell.trendtoMonitor, userstock.stockSymbol, userstock.lastpurchasePrice FROM autosell inner JOIN userstock ON autosell.userstockid = userstock.userstockid
"></asp:SqlDataSource>
    </ContentTemplate>
                    </ajaxToolkit:TabPanel>
<ajaxToolkit:TabPanel ID="tabAutoWatch" runat="server" HeaderText="Auto-Watch"></ajaxToolkit:TabPanel>
</ajaxToolkit:TabContainer>


            
</ContentTemplate>
</ajaxToolkit:TabPanel>

        <ajaxToolkit:TabPanel ID="tabMonitor" runat="server" HeaderText="Monitored Stocks">
            <ContentTemplate>
            <!-- Add grid view for monitored stocks -->
            <asp:GridView ID="gridViewMonitoredStocks" runat="server" 
                    AutoGenerateColumns="False" DataSourceID="monStockODS" >     
                <Columns>
                    <asp:BoundField DataField="Price" HeaderText="Price" ReadOnly="True" 
                        SortExpression="Price" />
                    <asp:BoundField DataField="CompanyName" HeaderText="CompanyName" 
                        ReadOnly="True" SortExpression="CompanyName" />
                    <asp:BoundField DataField="Symbol" HeaderText="Symbol" ReadOnly="True" 
                        SortExpression="Symbol" />
                    <asp:BoundField DataField="SharesOutstanding" HeaderText="SharesOutstanding" 
                        ReadOnly="True" SortExpression="SharesOutstanding" />
                </Columns>
            </asp:GridView>
            
                <asp:ObjectDataSource ID="monStockODS" runat="server" 
                    SelectMethod="retrieveMonitoredStocks" 
                    TypeName="WebTraderLiteCL.DBTransactions" 
                    onselecting="monStockODS_Selecting" DeleteMethod="deleteMonitoredStock" 
                    ondeleting="monStockODS_Deleting">
                    <SelectParameters>
                        <asp:Parameter Name="userID" Type="String" />
                    </SelectParameters>
                    <DeleteParameters>
                        <asp:Parameter Name="userName" Type="String" />
                        <asp:Parameter Name="Symbol" Type="String" />
                    </DeleteParameters>
                </asp:ObjectDataSource>
            
</ContentTemplate>
        
</ajaxToolkit:TabPanel>

        <ajaxToolkit:TabPanel ID="tabTransactions" runat="server" HeaderText="Transaction History">
            <ContentTemplate>
                <!-- Add grid view for trnasaction history -->
                <asp:GridView ID="gridViewTransHistory" runat="server" 
                    AutoGenerateColumns="False" DataSourceID="wtlDataSource" 
                    AllowSorting="True">
                    <Columns>
                        <asp:BoundField DataField="historyType" HeaderText="Transaction" 
                            SortExpression="historyType" />
                        <asp:BoundField DataField="stock" HeaderText="Stock" SortExpression="stock" />
                        <asp:BoundField DataField="numShares" HeaderText="Num. Shares" 
                            SortExpression="numShares" />
                        <asp:BoundField DataField="price" HeaderText="Transaction Price" 
                            SortExpression="price" DataFormatString="{0:C}" />
                        <asp:BoundField DataField="dateofEvent" HeaderText="Date" 
                            SortExpression="dateofEvent" DataFormatString="{0:MM/dd/yyyy}" />
                    </Columns>
                </asp:GridView>
                <asp:SqlDataSource ID="wtlDataSource" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:webtraderliteConnectionString %>" 
                    ProviderName="<%$ ConnectionStrings:webtraderliteConnectionString.ProviderName %>" 
                    
                    SelectCommand="SELECT historyType, stock, numShares, price, dateofEvent FROM history WHERE (loginName = @userName)">
                </asp:SqlDataSource>
            </ContentTemplate>
        </ajaxToolkit:TabPanel>

    </ajaxToolkit:TabContainer>



</asp:Content>
